//
//  ViewController.m
//  01-UIViewHomeWork
//
//  Created by QC.L on 16/7/14.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "ViewController.h"
#import "UIView+Frame.h"
#define WIDETH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
#define COLORAUTO [UIColor colorWithRed:(arc4random()%256/255.0) green:(arc4random()%256/255.0) blue:(arc4random()%256/255.0) alpha:1.0]
@interface ViewController ()
@property (nonatomic, strong) UIImageView *imageBackground;
@property (nonatomic, strong) UIImageView *imageUser;
@property (nonatomic, strong) UIImageView *imagePass;
@property (nonatomic, strong) UIView *viewBlur;
@property (nonatomic, strong) UILabel *lableLine;
@property (nonatomic, strong) UIImageView *imageLagou;
@property (nonatomic, strong) UIView *userView;
@property (nonatomic, strong) UIView *viewUser;
@property (nonatomic, strong) UIView *viewPass;
@property (nonatomic, strong) UIButton *btnRegister;
@property (nonatomic, strong) UIButton *btnPass;
@property (nonatomic, strong) UIButton *btnSign;
@property (nonatomic, strong) UILabel *lableLineOne;
@property (nonatomic, strong) UILabel *lableLineTwo;
@property (nonatomic, strong) UILabel *lableOr;
@property (nonatomic, strong) UIButton *btnShoping;
@property (nonatomic, strong) UITextField *fieldUser;
@property (nonatomic, strong) UITextField *fieldPass;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.imageBackground = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDETH, HEIGHT)];
    self.imageBackground.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:_imageBackground];
    self.viewBlur = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDETH, HEIGHT)];
    self.viewBlur.backgroundColor = [UIColor lightGrayColor];
    self.viewBlur.alpha = 0.38;
    [self.view addSubview:_viewBlur];
    [self creatLagouImage];
    [self creatUserPassBack];
    [self creatBtnRegister];
    [self creatBtnAndLable];
}
- (void)creatLagouImage {
    self.imageLagou = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.27, HEIGHT * 0.24)];
    self.imageLagou.backgroundColor = [UIColor clearColor];
    self.imageLagou.center = CGPointMake(self.viewBlur.frame.size.width / 2, HEIGHT * 0.31);
    self.imageLagou.image = [UIImage imageNamed:@"logo_lagou"];
    [self.view addSubview:_imageLagou];
}
- (void)creatUserPassBack {
    self.userView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDETH *0.95, HEIGHT * 0.125)];
    self.userView.center = CGPointMake(WIDETH / 2, HEIGHT * 0.55);
    self.userView.layer.cornerRadius = 10;
    self.userView.backgroundColor = [UIColor colorWithRed:0.28 green:0.27 blue:0.26 alpha:1.00];
    self.lableLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.userView.frame.size.width, 2)];
    self.lableLine.backgroundColor = [UIColor grayColor];
    self.lableLine.center = self.userView.center;
    [self.view addSubview:_userView];
    [self.view addSubview:_lableLine];
    self.fieldUser = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, self.userView.frame.size.width, self.userView.frame.size.height / 2 - self.lableLine.frame.size.height / 2)];
    self.fieldUser.backgroundColor = [UIColor clearColor];
    self.fieldUser.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.userView.frame.size.height / 2 - self.lableLine.frame.size.height / 2, self.userView.frame.size.height / 2 - self.lableLine.frame.size.height / 2)];
    self.fieldUser.leftView.backgroundColor = [UIColor colorWithRed:0.12 green:0.09 blue:0.07 alpha:1.00];
    self.fieldUser.leftViewMode = UITextFieldViewModeAlways;
    [self.userView addSubview:_fieldUser];
    self.fieldPass = [[UITextField alloc] initWithFrame:CGRectMake(0, self.fieldUser.frame.size.height + self.fieldUser.frame.origin.y + self.lableLine.frame.size.height, self.fieldUser.frame.size.width, self.fieldUser.frame.size.height)];
    self.fieldPass.backgroundColor = [UIColor clearColor];
    self.fieldPass.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.fieldUser.leftView.frame.size.width, self.fieldUser.leftView.frame.size.height)];
    self.fieldPass.leftView.backgroundColor = [UIColor colorWithRed:0.12 green:0.09 blue:0.07 alpha:1.00];
    self.fieldPass.leftViewMode =UITextFieldViewModeAlways;
    //    fieldUser的UIBezierPath
    UIBezierPath *maskPathUser = [UIBezierPath bezierPathWithRoundedRect:self.fieldUser.leftView.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayerUser = [[CAShapeLayer alloc] init];
    maskLayerUser.frame = self.fieldUser.leftView.bounds;
    maskLayerUser.path = maskPathUser.CGPath;
    self.fieldUser.leftView.layer.mask = maskLayerUser;
    [self.userView addSubview:_fieldUser];
    //    fieldPass的UIBezierPath
    UIBezierPath *maskPathPass = [UIBezierPath bezierPathWithRoundedRect:self.fieldPass.leftView.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayerPass = [[CAShapeLayer alloc] init];
    maskLayerPass.frame = self.fieldPass.leftView.bounds;
    maskLayerPass.path = maskPathPass.CGPath;
    self.fieldPass.leftView.layer.mask = maskLayerPass;
    [self.userView addSubview:_fieldPass];
    self.imageUser = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, 30, self.fieldUser.frame.size.height - 10)];
    self.imageUser.image = [UIImage imageNamed:@"icon_username"];
    self.imagePass = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageUser.frame.origin.x, 5, self.imageUser.frame.size.width, self.imageUser.frame.size.height)];
    self.imagePass.image = [UIImage imageNamed:@"icon_password"];
    [self.fieldUser.leftView addSubview:_imageUser];
    [self.fieldPass.leftView addSubview:_imagePass];
}


- (void)creatBtnRegister {
    self.btnRegister = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.95, HEIGHT * 0.06)];
    self.btnRegister.backgroundColor = [UIColor colorWithRed:0.00 green:0.71 blue:0.54 alpha:1.00];
    self.btnRegister.layer.cornerRadius = 5;
    [self.btnRegister setTitle:@"登录" forState:UIControlStateNormal];
    self.btnRegister.center = CGPointMake(WIDETH / 2, HEIGHT * 0.672);
    [self.view addSubview:_btnRegister];
    self.btnPass = [[UIButton alloc] initWithFrame:CGRectMake(self.btnRegister.frame.origin.x, self.btnRegister.frame.origin.y + self.btnRegister.frame.size.height + 20, WIDETH * 0.15, HEIGHT * 0.035)];
    self.btnPass.titleLabel.font = [UIFont systemFontOfSize:15.5];
    [self.btnPass setTitle:@"忘记密码" forState:UIControlStateNormal];
    self.btnPass.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_btnPass];
    self.lableOr = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.15, HEIGHT * 0.03)];
    self.lableOr.center = CGPointMake(WIDETH / 2, HEIGHT * 0.88);
    self.lableOr.text = @"or";
    self.lableOr.textAlignment = 1;
    self.lableOr.textColor = [UIColor whiteColor];
    self.lableOr.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_lableOr];
    self.lableLineOne = [[UILabel alloc] initWithFrame:CGRectMake(self.btnRegister.frame.origin.x, self.lableOr.center.y, self.btnRegister.frame.size.width / 2 - self.lableOr.frame.size.width / 2, 2)];
    self.lableLineTwo = [[UILabel alloc] initWithFrame:CGRectMake(self.lableLineOne.frame.size.width + self.lableOr.frame.size.width + self.lableLineOne.frame.origin.x, self.lableLineOne.frame.origin.y, self.lableLineOne.frame.size.width, self.lableLineOne.frame.size.height)];
    self.lableLineTwo.backgroundColor = [UIColor whiteColor];
    self.lableLineOne.backgroundColor = [UIColor whiteColor];
    self.btnShoping = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.25, HEIGHT * 0.023)];
    [self.btnShoping setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [self.btnShoping setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.btnShoping.backgroundColor = [UIColor clearColor];
    self.btnShoping.center = CGPointMake(WIDETH / 2, HEIGHT * 0.932);
    [self.view addSubview:_btnShoping];
    [self.view addSubview:_lableLineTwo];
    [self.view addSubview:_lableLineOne];
}
- (void)creatBtnAndLable {
    self.btnSign = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.4, HEIGHT * 0.025)];
    self.btnSign.backgroundColor = [UIColor clearColor];
    self.btnSign.center = CGPointMake(WIDETH / 2, HEIGHT * 0.82);
    
    [self.btnSign setTitle:@"现在注册拉钩" forState:UIControlStateNormal];
    [self.btnSign setTitleColor:[UIColor colorWithRed:0.00 green:0.58 blue:0.44 alpha:1.00] forState:UIControlStateNormal];
    [self.view addSubview:_btnSign];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
